import Vue from 'vue'
import VueRouter from 'vue-router'
// @ 代表的是 src
import Login from '@/views/Login.vue'
//处理多次点击 路由报错的情况
let originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(path){
  return originalPush.call(this,path).catch(err=>err)
}
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Login',
    component: Login
  },
  {
    path: '/about',
    name: 'About',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  },
  {
    path: '/dashboard',
    // name: 'dashboard',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "dashboard" */ '@/components/dashboard/Dashboard'),
    children:[
      {
        path:"/",
         name:"home",
        component:()=>import("@/components/dashboard/Home"),
        meta:["数据管理"]
      },
      {
        path:"/userlist",
        name:"userlist",
        component:()=>import("@/components/dashboard/UserList"),
        meta:["数据管理","用户列表"]
      },
      {
        path:"/adminlist",
        name:"adminlist",
        component:()=>import("@/components/dashboard/AdminList"),
        meta:["数据管理","管理员列表"]
      },
      {
        path:"/orderlist",
        name:"orderlist",
        component:()=>import("@/components/dashboard/OrderList"),
        meta:["数据管理","订单列表"]
      },
      {
        path:"/foodlist",
        name:"foodlist",
        component:()=>import("@/components/dashboard/FoodList"),
        meta:["数据管理","食品列表"]
      },
      {
        path:"/shoplist",
        name:"shoplist",
        component:()=>import("@/components/dashboard/ShopList"),
        meta:["数据管理","商店列表"]
      }

    ]
  }
]

const router = new VueRouter({
  routes
})

export default router
